package cn.server.util;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;

import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class ConfUtil {

	private static Properties pro = null;

	private static final Log logger = LogFactory.getLog(ConfUtil.class);

	public static synchronized void init() {
		if (pro != null)
			return;
		pro = new Properties();
		InputStream in = null;
		try {
			in = new FileInputStream("config/conf.properties");
			pro.load(in);
		} catch (Throwable e) {
			logger.error("init config error", e);
		} finally {
			IOUtils.closeQuietly(in);
		}
	}

	public static String getValue(String key) {
		return pro.getProperty(key);
	}

	public static String getValue(String key, String def) {
		return pro.getProperty(key, def);
	}
}
